package xkp.lesson.handler;

import com.sun.deploy.net.HttpResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/hello4")
public class Hello4Controller {

    @GetMapping("/tosuccess.action")
    public ModelAndView toSuccess(){
        System.out.println("to success -------------");
        ModelAndView mv = new ModelAndView();
        mv.setViewName("success");
        mv.addObject("message","你好，天气不错!!!");
        return mv;
    }

    @GetMapping("/test1.action")
    public String test1(Model model){
        model.addAttribute("message","你好，天气不错!!!");
        return "forward:test2.action";
    }

    @GetMapping("/test2.action")
    public String test2(HttpServletRequest request){
        HttpSession session = request.getSession();
        return "redirect:/index.jsp";
    }
}
